Presenting the Default Interface
If your application has no special interface requirements, you can use the
boxes for opening and saving documents.
enhancements, most of which have no effect on your application. Most noticeably, the
system 7.0 standard file dialog boxes use a slightly different point of view. Instead of
displaying only one volume at a time and showing the root of that volume at the top of
the hierarchy, the file list now displays all mounted volumes and shows the desktop as
the top level of the hierarchy. The Drive button, which previously allowed users to
move among all mounted volumes, is now the Desktop button, which returns the display to the top of the hierarchy.
You use the StandardGetFile procedure when you want to let the user choose a file to be opened. The first Figure below illustrates a sample dialog box displayed by
The default Open dialog box When you call StandardGetFile, you can supply a list of the file types that your application can open. StandardGetFile then displays only files of the specified types. You can also supply your own filter function to determine which files are displayed.
(See Opening Files for details.)
When the user is opening a document, StandardGetFile interprets keystrokes as selectors in the displayed list. Pressing A, for example, selects the first item in the
list that starts with the letter a (or, if no items in the list start with the letter a, the
timer on keystrokes: keystrokes in rapid succession form a string; keystrokes spaced
in time are processed separately.
When the user is saving a document, StandardPutFile can direct keystrokes to either of two targets: the filename field or the displayed list. When the dialog box first
appears, keystrokes are directed to the filename field. If the user presses the Tab key
or clicks to select an item in the displayed list, subsequent keystrokes are interpreted
as selectors in the displayed list. Each time the user presses the Tab key, keyboard
input shifts between the two targets. (The list at the end of this section describes all
keystrokes that affect the standard file dialog boxes.)
When the user is saving a file, the new Save dialog box offers the option of creating a
new folder, as illustrated below.
The default Save dialog box
subsidiary dialog box like the example below.
The New Folder dialog box If the user asks to save a file with a name that already exists at the specified location,
file should replace the existing file.
The name conflict dialog box
system 7.0, unless the application has customized the dialog box. For more details on
Compatibility With Earlier Procedures under
the user completes the dialog box-either by selecting a file and clicking Save or
Open, or by clicking Cancel. Your application checks the values in the reply record to see what action to take, if any. If the selected item is an alias for another item, the
description of aliases.)
File Manager. The new reply record identifies files with file system specification records, which are recognized by a new set of high-level File Manager functions. file system specification records.)
The following code example illustrates how an application calls first the
// Opening a document
// Assuming inclusion of
void LetMeCheck (OSErr fsOpenErr);
SFTypeList myTypeList; // list of types to display OSErr fsOpenErr; // error returned by open function short fsRefNum; // by open function
myTypeList[0] = 'MDOC'; // set up type list
myTypeList[1] = 'YDOC';
if (mySFR.sfGood) ˜// user clicks Open
{
fsOpenErr = FSpOpenDF(&mySFR.sfFile, fsCurPerm, &fsRefNum); // open the file
LetMeCheck(fsOpenErr); ˜// routine to check errors
// open document through reference number returned by FSpOpenDF }
during dialogs.
Keystrokes Action
Up Arrow Scroll up (backward) through displayed
list
Down Arrow Scroll down (forward) through
displayed list
Command-Up Arrow Display contents of parent
Command-Down Arrow Display contents of selected directory or
Command-Left Arrow Display contents of previous volume
Command-Right Arrow Display contents of next volume
Command-Shift-Up Arrow Display contents of desktop
Command-Shift-1 Eject disk in drive 1 Command-Shift-2 Eject disk in drive 2 Tab Move to next keyboard target
Return or Enter Invoke the default option for the dialog
Escape or Command-. Cancel
Command-O Open the selected item Command-D Display contents of desktop
Command-N Create a new folder
Option-Command-O or
Option-[click Open] Select the target of the selected alias
item instead of opening it
When the user selects a button in the dialog box using a keyboard equivalent, the
button flashes.